﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using dhDataAcess.orderLinqDAL;
using dhSystemBLL.orderData;
using baseSet.importExport;
using dhDataAcess.dataAcess.orderDataSetTableAdapters;
using dhDataAcess.dataAcess;
using dhsystem.produceForm;
using dhsystem.Main;
using baseSet;
using dhDataAcess.baseBLL;
using FastReport;

namespace dhsystem.orderForm
{
    public partial class FrmPbomMasterAdd : Form
    {
        pbomMarkBLL pbomMark = new pbomMarkBLL();
        pbomMarkModel pboMarkRow = new pbomMarkModel();
        orderDataSet.pbomDetailDataTable pbomDetailTable = new orderDataSet.pbomDetailDataTable();
        pbomDetailModel pbomDetailRow = new pbomDetailModel();
        pbomDetailBLL pbomDetailbll = new pbomDetailBLL();
        pbomMasterBLL pbomMaster = new pbomMasterBLL();
        pbomMasterModel pbomMasterRow = new pbomMasterModel();
        custListBLL custList = new custListBLL();
        BindingSource b2;
        string pname;
        string state;

       // string cValue;
        //绑定数据源
        public FrmPbomMasterAdd(BindingSource b1, string _state, string _pname)
        {
            InitializeComponent();
            state = _state;
            b2=b1;
            pname = _pname;
        }
        //打开窗口时绑定数据
        private void FrmPbomMasterAdd_Load(object sender, EventArgs e)
        {
            
            textrequest.Text = "90%";
            textspeedKf.Text = "900";
            textspeedNf.Text = "1100";
            textnumberKf.Text = "648";
            textnumberNf.Text = "792";
            textzzrequest.Text = "90%";
            if (state == "新增")
            {

                textpname.Text = pname;
                bindingSourcePbomDetail.DataSource = pbomDetailbll.getpbomDetailbypanmeAll(textpname .Text );
                dGridDetail.DataSource = bindingSourcePbomDetail;
             
            }
            bindingSourcecustList.DataSource = custList.getcustListAll();
            comboBoxcustNum.DataSource = bindingSourcecustList;
            comboBoxcustNum.DisplayMember = "custName";
            comboBoxcustNum.ValueMember = "custNum";
            
            if (state == "编辑")
            {
                bindingSource1.DataSource = pbomMark.getpbomMarkAllBypname(pname);
                textpname.DataBindings.Add("text", b2, "pname");
                comboBoxcustNum.DataBindings.Add("SelectedValue", b2, "custNum");
                textmachineType.DataBindings.Add("text", b2, "machineType");
                textbweight.DataBindings.Add("text", b2, "bweight");
                textawgight.DataBindings.Add("text", b2, "awgight");
                textmark.DataBindings.Add("text", b2, "mark");
                textgqDensity.DataBindings.Add("text", bindingSource1, "gqDensity");
                textdifficulty.DataBindings.Add("text", bindingSource1, "difficulty");
                textzwDensity.DataBindings.Add("text", bindingSource1, "zwDensity");
                texttwoLength.DataBindings.Add("text", bindingSource1, "twoLength");
                textstartopen.DataBindings.Add("text", bindingSource1, "startopen");
                textstartshrink.DataBindings.Add("text", bindingSource1, "startshrink");
                textstartwidth.DataBindings.Add("text", bindingSource1, "startwidth");
                textendopen.DataBindings.Add("text", bindingSource1, "endopen");
                textendshrink.DataBindings.Add("text", bindingSource1, "endshrink");
                textendwidth.DataBindings.Add("text", bindingSource1, "endwidth");
                textproductionNf.DataBindings.Add("text", bindingSource1, "productionNf");
                textproductionKf.DataBindings.Add("text", bindingSource1, "productionKf");
                //textmethods.DataBindings.Add("text", bindingSource1, "methods");

                textzzrequest.DataBindings.Add("text", bindingSource1, "zzrequest");
                textzzdifficulty.DataBindings.Add("text", bindingSource1, "zzdifficulty");
                textzzproduceqty.DataBindings.Add("text", bindingSource1, "zzproduceqty");
                textzzzwDensity.DataBindings.Add("text", bindingSource1, "zzzwDensity");
                //textzzbasicspec.DataBindings.Add("text", bindingSource1, "zzbasicspec");
                textzzproduction.DataBindings.Add("text", bindingSource1, "zzproduction");
                texzzspeed.DataBindings.Add("text", bindingSource1, "zzspeed");
                textzzyujiproduction.DataBindings.Add("text", bindingSource1, "zzyujiproduction");
                textzzmachineqty.DataBindings.Add("text", bindingSource1, "zzmachineqty");
                textzzzwjgtx.DataBindings.Add("text", bindingSource1, "zzzwjgtx");
                bindingSourcePbomDetail.DataSource = pbomDetailbll.getpbomDetailbypanmeAll(textpname.Text );
                dGridDetail.DataSource = bindingSourcePbomDetail;             
            }
            DcolumnSet.colSet(moduleInfo.pbomDetail, dGridDetail);
            dGridDetail.AllowUserToAddRows = true;

            dGridDetail.Columns[3].ReadOnly = true;

            this.KeyPreview = true;

            dGridDetail.EditMode = DataGridViewEditMode.EditOnEnter ;
            //改变字体大小
            foreach (Control item in Controls)
            {
                ClassSetControlFontSize.listInfor.Add(item);
                ClassSetControlFontSize.listInfor.Add(item.Font.Size);
            }
        }
        
        //双击原材料所在行单元格事件
        private void dGridDetail_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string field;
            field = "matNum";
            int colIndex = dGridDetail.Columns["matNum"].Index;
            int colIndexmark = dGridDetail.Columns["mark"].Index;
            if (colIndex == e.ColumnIndex)
            {
                Frmprodutselect select = new Frmprodutselect(moduleInfo.materialList, field);
                DialogResult result = select.ShowDialog();
                if (result == DialogResult.Yes)
                {
                   
                    dGridDetail.CurrentCell.Value = select.pname;
                }
            }
                if (colIndexmark  == e.ColumnIndex)
            {
                Frmmark mark = new Frmmark();
                DialogResult result = mark.ShowDialog();
                if (result == DialogResult.Yes)
                {

                    dGridDetail.CurrentCell.Value = mark.mark ;
                }
            }
        }
        //外部数据分析
        private void dGridDetail_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            if (e.ColumnIndex == dGridDetail.Columns["pweight"].Index)
            {
                MessageBox.Show(e.Exception.Message.ToString());
            }
            MessageBox.Show(e.Exception.Message.ToString());
        }
 
        /// <summary>  
        /// 设置编辑状态下按回车键，跳到指定单元格.  
        /// </summary>  
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            string field;
            field = "matNum";
            //cValue = dGridDetail.CurrentRow.Cells[3].EditedFormattedValue.ToString();
            if (keyData == Keys.Enter)    //监听回车事件   
            {
                if (this.dGridDetail.IsCurrentCellInEditMode)   //如果当前单元格处于编辑模式   
                {
                   
                    if (this.dGridDetail.CurrentCell.ColumnIndex == 2)
                    {
                        //cValue= dGridDetail.CurrentRow.Cells[3].EditedFormattedValue.ToString();
                        Frmprodutselect select = new Frmprodutselect(moduleInfo.materialList, field);
                        DialogResult result = select.ShowDialog();
                        if (result == DialogResult.Yes)
                        {
                            //dGridDetail.CurrentCell.Value = select.pname;

                            dGridDetail.CurrentRow.Cells["matNum"].Value = select.pname;
                            //dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[4];
                        }
                    }

                    if (this.dGridDetail.CurrentCell.ColumnIndex != 11)
                    {
                        SendKeys.Send("{Up}");
                        SendKeys.Send("{Tab}");
                       // SendKeys.Send("{Tab}");
                    }

                    else
                    {
                        SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); 
                        SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); SendKeys.Send("{LEFT}"); 
                    }
                }
                else
                {
                    SendKeys.Send("{Up}");
                    SendKeys.Send("{Tab}");
                    //SendKeys.Send("{Tab}");
                    //SendKeys.Send("{Tab}");
                }


            }

            if (keyData == Keys.F3)
            {
                int cRowIndex = dGridDetail.CurrentCell.RowIndex;
                int cCellIndex = dGridDetail.CurrentCell.ColumnIndex;
                dGridDetail.CurrentCell.Value = dGridDetail.Rows[cRowIndex - 1].Cells[cCellIndex].Value;
                if (cCellIndex == 2||cCellIndex ==0)
                {
                    dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex +3];
                    dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex];
                }
                else
                {
                    dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex - 1];
                    dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex];
                }
            }
       
            //继续原来base.ProcessCmdKey中的处理   
            return base.ProcessCmdKey(ref msg, keyData);
            
        }
        //产品名称选择按钮
        private void button1_Click(object sender, EventArgs e)
        {
            string field;
            field = "pname";
            Frmprodutselect productselect = new Frmprodutselect(moduleInfo.productList, field);
            DialogResult result = productselect.ShowDialog();
            if (result == DialogResult.Yes)
            {
                textpname.Text = productselect.pname;
            }
        }

        //菜单栏删除按钮
        private void toolDel_Click(object sender, EventArgs e)
        {
            try
            {
                string id = dGridDetail.Rows[dGridDetail.CurrentRow.Index].Cells[0].Value.ToString();
                DialogResult result = MessageBox.Show("是否删除：" + id + "！", "提示信息", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    dGridDetail.Rows.Remove(dGridDetail.CurrentRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //菜单栏保存按钮
        private void toolSave_Click(object sender, EventArgs e)
        {
            if (textpname.Text == "")
            {
                MessageBox.Show("请选择产品名称");
            }
            else
            {
                try
                {
                    DialogResult result = MessageBox.Show("是否保存产品BOM主表信息！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        tabControl1.SelectedIndex=1;
                      
                        dhDataAcess.dataAcess.orderDataSet.pbomDetailDataTable ptable = (dhDataAcess.dataAcess.orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                        pbomMasterRow.pname = textpname.Text;
                        pbomMasterRow.custNum = comboBoxcustNum.SelectedValue.ToString();
                        pbomMasterRow.machineType = textmachineType.Text;
                        pbomMasterRow.bweight = Convert.ToDecimal(textbweight.Text);
                        pbomMasterRow.awgight = Convert.ToDecimal(textawgight.Text);
                        pbomMasterRow.zbr = "";
                        pbomMasterRow.spr = "";
                        pbomMasterRow.checkDate = DateTime.Now;
                        pbomMasterRow.createDate = DateTime.Now;
                        pbomMasterRow.createUser = "";
                        pbomMasterRow.updateDate = DateTime.Now;
                        pbomMasterRow.updateUser = "";
                        pbomMasterRow.mark = textmark.Text;

                        pboMarkRow.pname = textpname.Text;
                        pboMarkRow.request = textrequest.Text;
                        pboMarkRow.gqDensity = textgqDensity.Text;
                        pboMarkRow.difficulty = textdifficulty.Text;
                        pboMarkRow.zwDensity = textzwDensity.Text ;

                       pboMarkRow.twoLength = texttwoLength.Text;
                        pboMarkRow.startopen = textstartopen.Text;
                        pboMarkRow.startshrink = textstartshrink.Text;
                        pboMarkRow.startwidth = textstartwidth.Text;
                        pboMarkRow.endopen = textendopen.Text;
                        pboMarkRow.endshrink = textendshrink.Text;
                        pboMarkRow.endwidth = textendwidth.Text;
                        if (textproductionKf.Text != "")
                        {
                            pboMarkRow.productionKf = Convert.ToDecimal(textproductionKf.Text);
                        }
                        else { pboMarkRow.productionKf = 0; }
                        if (textproductionNf.Text != "")
                        {
                            pboMarkRow.productionNf = Convert.ToDecimal(textproductionNf.Text);
                        }
                        else { pboMarkRow.productionNf = 0; }
                        pboMarkRow.speedKf = textspeedKf.Text ;
                        pboMarkRow.speedNf = textspeedNf.Text;
                        pboMarkRow.methods = "";
                        pboMarkRow.numberKf = textnumberKf.Text;
                        pboMarkRow.numberNf = textnumberNf.Text;
                        pboMarkRow.mark = "";
                        pboMarkRow.zzrequest = textzzrequest.Text;
                        pboMarkRow.zzdifficulty = textzzdifficulty.Text;
                        pboMarkRow.zzproduceqty = textzzproduceqty.Text;
                        pboMarkRow.zzzwDensity = textzzzwDensity.Text;
                        pboMarkRow.zzbasicspec = "";
                        pboMarkRow.zzproduction = textzzproduction.Text;
                        pboMarkRow.zzspeed = texzzspeed.Text;
                        pboMarkRow.zzzwjgtx = textzzzwjgtx.Text;
                        pboMarkRow.zzyujiproduction = textzzyujiproduction.Text;
                        pboMarkRow.zzmachineqty = textzzmachineqty.Text;
                        pbomMaster.pbomMasterInsert(pboMarkRow ,pbomMasterRow, ptable, state,textpname .Text );
                        ptable.AcceptChanges();
                        bindingSourcepbomMaster.DataSource = pbomMaster.getpbomMasterAll();
                        MessageBox.Show("保存成功");
                    }
                }
                catch (FormatException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }
        //状态栏退出按钮
        private void toolExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        //客户编号选中按钮
        private void buttselectcustNum_Click(object sender, EventArgs e)
        {
            string field;
            field = "custNum";
            Frmprodutselect productselect = new Frmprodutselect(moduleInfo.custList ,field );
            DialogResult result = productselect.ShowDialog();
            if (result == DialogResult.Yes)
            {
                comboBoxcustNum .SelectedValue  = productselect.pname;
            }
        }

        //单元格内容跟上一行相同
        private void button4_Click(object sender, EventArgs e)
        {
            MessageBox.Show("请按F3键实现该功能");
        }

        private void 插入空行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dGridDetail.Rows.Count != 1)
                {
                    orderDataSet.pbomDetailDataTable detailTable = (orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                    orderDataSet.pbomDetailRow insertRow = detailTable.NewpbomDetailRow();
                    detailTable.Rows.InsertAt((DataRow)insertRow, dGridDetail.CurrentRow.Index + 1);
                    bindingSourcePbomDetail.MoveNext();
                }
                else
                {
                    MessageBox.Show("不存在需要插入的行");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选需要插入空行的位置");
            }
        }

        private void 复制选中的内容ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dGridDetail.Rows.Count != 1)
                {
                    orderDataSet.pbomDetailDataTable detailTable = (orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                    orderDataSet.pbomDetailRow insertRow = detailTable.NewpbomDetailRow();
                    int recordID = Convert.ToInt32(dGridDetail.CurrentRow.Cells["recordID"].Value.ToString());
                    orderDataSet.pbomDetailRow crreentRow = detailTable.FindByrecordid(recordID);
                    insertRow.wb = crreentRow.wb;
                    insertRow.matNum = crreentRow.matNum;
                    insertRow.pt = crreentRow.pt;
                    insertRow.pz = crreentRow.pz;
                    insertRow.ts = crreentRow.ts;
                    insertRow.blen = crreentRow.blen;
                    insertRow.pweight = crreentRow.pweight;
                    insertRow.alen = crreentRow.alen;
                    insertRow.aweight = crreentRow.aweight;
                    insertRow.mark = crreentRow.mark;
                    detailTable.AddpbomDetailRow(insertRow);
                    bindingSourcePbomDetail.MoveLast();
                    bindingSourcePbomDetail.EndEdit();
                }
                else
                {
                    MessageBox.Show("不存在需要复制的行");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选择要复制的行");
            }
        }

        private void 复制插入ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dGridDetail.Rows.Count != 1)
                {
                    orderDataSet.pbomDetailDataTable detailTable = (orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                    orderDataSet.pbomDetailRow insertRow = detailTable.NewpbomDetailRow();
                    int recordID = Convert.ToInt32(dGridDetail.CurrentRow.Cells["recordID"].Value.ToString());
                    orderDataSet.pbomDetailRow crreentRow = detailTable.FindByrecordid(recordID);
                    insertRow.wb = crreentRow.wb;
                    insertRow.matNum = crreentRow.matNum;
                    insertRow.pt = crreentRow.pt;
                    insertRow.pz = crreentRow.pz;
                    insertRow.ts = crreentRow.ts;
                    insertRow.blen = crreentRow.blen;
                    insertRow.pweight = crreentRow.pweight;
                    insertRow.alen = crreentRow.alen;
                    insertRow.aweight = crreentRow.aweight;
                    insertRow.mark = crreentRow.mark;
                    detailTable.Rows.InsertAt((DataRow)insertRow, dGridDetail.CurrentRow.Index + 1);
                    bindingSourcePbomDetail.MoveNext();
                    bindingSourcePbomDetail.EndEdit();
                }
                else
                {
                    MessageBox.Show("不存在需要复制的行");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选择要插入的行的位置");
            }
        }

        private void 复制单元格ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int cRowIndex = dGridDetail.CurrentCell.RowIndex;
            int cCellIndex = dGridDetail.CurrentCell.ColumnIndex;
            dGridDetail.CurrentCell.Value = dGridDetail.Rows[cRowIndex - 1].Cells[cCellIndex].Value;
            if (cCellIndex == 2 || cCellIndex == 0)
            {
                dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex + 3];
                dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex];
            }
            else
            {
                dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex - 1];
                dGridDetail.CurrentCell = dGridDetail.CurrentRow.Cells[cCellIndex];
            }
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            try
            {
                if (dGridDetail.Rows.Count != 1)
                {
                    orderDataSet.pbomDetailDataTable detailTable = (orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                    orderDataSet.pbomDetailRow insertRow = detailTable.NewpbomDetailRow();
                    int recordID = Convert.ToInt32(dGridDetail.CurrentRow.Cells["recordID"].Value.ToString());
                    orderDataSet.pbomDetailRow crreentRow = detailTable.FindByrecordid(recordID);
                    insertRow.wb = crreentRow.wb;
                    insertRow.matNum = crreentRow.matNum;
                    insertRow.pt = crreentRow.pt;
                    insertRow.pz = crreentRow.pz;
                    insertRow.ts = crreentRow.ts;
                    insertRow.blen = crreentRow.blen;
                    insertRow.pweight = crreentRow.pweight;
                    insertRow.alen = crreentRow.alen;
                    insertRow.aweight = crreentRow.aweight;
                    insertRow.mark = crreentRow.mark;
                    detailTable.AddpbomDetailRow(insertRow);
                    bindingSourcePbomDetail.MoveLast();
                    bindingSourcePbomDetail.EndEdit();
                }
                else
                {
                    MessageBox.Show("不存在需要复制的行");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选择要复制的行");
            }
        }

        private void 删除行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string id = dGridDetail.Rows[dGridDetail.CurrentRow.Index].Cells[0].Value.ToString();
                DialogResult result = MessageBox.Show("是否删除：" + id + "！", "提示信息", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    dGridDetail.Rows.Remove(dGridDetail.CurrentRow);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

        }
        //菜单栏新增按钮
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            state = "新增";
            textpname.Text = "";
            textawgight.Text = "";
            textbweight.Text = "";
            textmachineType .Text = "";
            textmark.Text = "";
            bindingSourcePbomDetail.DataSource = pbomDetailbll.getpbomDetailbypanmeAll(textpname.Text);
            dGridDetail.DataSource = bindingSourcePbomDetail;

            bindingSourcecustList.DataSource = custList.getcustListAll();
            comboBoxcustNum.DataSource = bindingSourcecustList;
            comboBoxcustNum.DisplayMember = "custName";
            comboBoxcustNum.ValueMember = "custNum";

            DcolumnSet.colSet(moduleInfo.pbomDetail, dGridDetail);
            dGridDetail.AllowUserToAddRows = true;
            dGridDetail.Columns[3].ReadOnly = true;
            dGridDetail.EditMode = DataGridViewEditMode.EditOnKeystroke;
            this.KeyPreview = true;
        }

        private void 复制上一行ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (dGridDetail.Rows.Count != 1)
                {
                    orderDataSet.pbomDetailDataTable detailTable = (orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                    orderDataSet.pbomDetailRow insertRow = detailTable.NewpbomDetailRow();
                    int recordID = Convert.ToInt32(dGridDetail.CurrentRow.Cells["recordID"].Value.ToString());
                    int cRowIndex = dGridDetail.CurrentCell.RowIndex;
                    orderDataSet.pbomDetailRow crreentRow = detailTable.FindByrecordid(cRowIndex -1);
                    insertRow.wb = crreentRow.wb;
                    insertRow.matNum = crreentRow.matNum;
                    insertRow.pt = crreentRow.pt;
                    insertRow.pz = crreentRow.pz;
                    insertRow.ts = crreentRow.ts;
                    insertRow.blen = crreentRow.blen;
                    insertRow.pweight = crreentRow.pweight;
                    insertRow.alen = crreentRow.alen;
                    insertRow.aweight = crreentRow.aweight;
                    insertRow.mark = crreentRow.mark;
                    detailTable.AddpbomDetailRow(insertRow);
                    bindingSourcePbomDetail.MoveLast();
                    bindingSourcePbomDetail.EndEdit();
                }
                else
                {
                    MessageBox.Show("不存在需要复制的行");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("请选择要复制的行");
            }
        }


        //texttwoLength的值发生改变时
        private void texttwoLength_TextChanged(object sender, EventArgs e)
        {
            
                textproductionKf.Text = Convert.ToString(Convert.ToDouble(texttwoLength.Text) * 648 * 0.9);
                textproductionNf.Text = Convert.ToString(Convert.ToDouble(texttwoLength.Text) * 792 * 0.9);
       
        }

        private void dGridDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            decimal bweightqty=0 ;
            decimal awgightqty =0;
            if (dGridDetail.Rows.Count > 0 && e.RowIndex >= 0)
            {
                DataGridViewRow row = dGridDetail.Rows[e.RowIndex];
                if (row.Cells[e.ColumnIndex].OwningColumn.Name == "matNum" || row.Cells[e.ColumnIndex].OwningColumn.Name == "pweight" || row.Cells[e.ColumnIndex].OwningColumn.Name == "aweight")
                {
                    try
                    {
                        //decimal account;
                        //account = Convert.ToDecimal(dGridDetail.Rows[e.RowIndex].Cells["qty"].Value) * Convert.ToDecimal(dGridDetail.Rows[e.RowIndex].Cells["price"].Value);
                        //dGridDetail.Rows[e.RowIndex].Cells["account"].Value = Convert.ToDecimal(dGridDetail.Rows[e.RowIndex].Cells["qty"].Value) * Convert.ToDecimal(dGridDetail.Rows[e.RowIndex].Cells["price"].Value);
                        //dGridDetail.Rows[e.RowIndex].Cells["account"].ReadOnly = true;
                        row.Cells["matName"].Value = basicSql.getmatNamebymaterialList (row.Cells["matNum"].Value.ToString());
                        //数量或单价更改后,重新计算 数量合计和金额合计

                        for (int i = 0; i < dGridDetail.Rows.Count; i++)
                        {
                           // 统计数量合计
                            try
                            {      
                                    awgightqty += Convert.ToDecimal(dGridDetail.Rows[i].Cells["aweight"].Value);
                                    bweightqty += Convert.ToDecimal(dGridDetail.Rows[i].Cells["pweight"].Value);
                               

                            }
                            catch { }
                            ////统计金额合计
                            //try
                            //{
                            //    decAmountTotal += Convert.ToDecimal(dGridDetail.Rows[i].Cells["account"].Value);
                            //}
                            //catch { }
                        }

                        textbweight.Text = bweightqty.ToString();
                        textawgight.Text = awgightqty.ToString();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
        }
        //任务栏选择字体大小
        private void toolStripComboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            //记录选择字体大小信息，针对子窗体依然可以遵循该字体大小
            ClassSetControlFontSize.fAdd = float.Parse(this.toolStripComboBox1.Text);
            //combBox1的项应为数字
            ClassSetControlFontSize.SetControlFontStyle(float.Parse(toolStripComboBox1.Text)); 
        }

        private void label8_Click(object sender, EventArgs e)
        {

        }

        private void textzzproduction_TextChanged(object sender, EventArgs e)
        {

        }

        private void 梳织打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string pname = textpname .Text ;
            //  DataSetPrint.pbomTableDataTable pbomTable = new DataSetPrint.pbomTableDataTable();
            //  DataSetPrint.pbomDtailTableDataTable pbomDtailTable = new DataSetPrint.pbomDtailTableDataTable();
            //  DataSetPrint.pbomMarkDataTable pbomMarkTable = new DataSetPrint.pbomMarkDataTable();
            //  DataSetPrint.materialListTableDataTable materialListTable= new DataSetPrint.materialListTableDataTable();
            //  //string matNum = dGridPbomMaster.CurrentRow.Cells["matNum"].Value.ToString();
            //string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            //orderDataSet.pbomDetailDataTable pbomDetailTable = pbomDetail.getpbomDetailbypanmeAll(pname);
            //orderDataSet.pbomMarkDataTable pbomMarkTable2 = pbomMark.getpbomMarkAllBypname(pname);
            //orderDataSet.pbomMasterDataTable pbomMasterTable = pbomMaster.getpbomMasterAllBypname(pname);
            //orderDataSet.materialListDataTable material = materilList.getmaterialListAll  () ;

            #region 旧代码          foreach (orderDataSet.pbomMasterRow pbomMasterRow in pbomMasterTable)

            #endregion          }



            Report r = new Report();
            DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf = 0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            //ds.Tables.Add (pbomTable);
            //ds.Tables.Add(pbomDtailTable);
            //ds.Tables.Add(pbomMarkTable);
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomaster.frx");
            r.RegisterData(ds);
          r.Show();
           // r.Design();
        }

        private void zhenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string pname = textpname.Text;
            Report r = new Report();
            DataSet ds = new DataSet();
            // DataTable dt = new DataTable();
            // dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf = 0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            ds.Tables.Add(pbomTable);
            // r.Load(@"E:\东华软件项目\报表\pbomasterzhenzhi.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomasterzhenzhi.frx");
            r.RegisterData(ds);
            // r.Design();
            r.Show();
        }

        private void toolfugai_Click(object sender, EventArgs e)
        {
            if (textpname.Text == "")
            {
                MessageBox.Show("请选择产品名称");
            }
            else
            {
                try
                {
                    DialogResult result = MessageBox.Show("是否覆盖保存，以前资料将会被覆盖！", "提示信息", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        tabControl1.SelectedIndex = 1;

                        dhDataAcess.dataAcess.orderDataSet.pbomDetailDataTable ptable = (dhDataAcess.dataAcess.orderDataSet.pbomDetailDataTable)bindingSourcePbomDetail.DataSource;
                        pbomMasterRow.pname = textpname.Text;
                        pbomMasterRow.custNum = comboBoxcustNum.SelectedValue.ToString();
                        pbomMasterRow.machineType = textmachineType.Text;
                        pbomMasterRow.bweight = Convert.ToDecimal(textbweight.Text);
                        pbomMasterRow.awgight = Convert.ToDecimal(textawgight.Text);
                        pbomMasterRow.zbr = "";
                        pbomMasterRow.spr = "";
                        pbomMasterRow.checkDate = DateTime.Now;
                        pbomMasterRow.createDate = DateTime.Now;
                        pbomMasterRow.createUser = "";
                        pbomMasterRow.updateDate = DateTime.Now;
                        pbomMasterRow.updateUser = "";
                        pbomMasterRow.mark = textmark.Text;

                        pboMarkRow.pname = textpname.Text;
                        pboMarkRow.request = textrequest.Text;
                        pboMarkRow.gqDensity = textgqDensity.Text;
                        pboMarkRow.difficulty = textdifficulty.Text;
                        pboMarkRow.zwDensity = textzwDensity.Text;
                        pboMarkRow.twoLength = texttwoLength.Text;
                        pboMarkRow.startopen = textstartopen.Text;
                        pboMarkRow.startshrink = textstartshrink.Text;
                        pboMarkRow.startwidth = textstartwidth.Text;
                        pboMarkRow.endopen = textendopen.Text;
                        pboMarkRow.endshrink = textendshrink.Text;
                        pboMarkRow.endwidth = textendwidth.Text;
                        pboMarkRow.productionKf =Convert .ToInt32( textproductionKf.Text);
                        pboMarkRow.productionNf = Convert .ToInt32(textproductionNf.Text);
                        pboMarkRow.speedKf = textspeedKf.Text;
                        pboMarkRow.speedNf = textspeedNf.Text;
                        pboMarkRow.methods = "";
                        pboMarkRow.numberKf = textnumberKf.Text;
                        pboMarkRow.numberNf = textnumberNf.Text;
                        pboMarkRow.mark = "";
                        pboMarkRow.zzrequest = textzzrequest.Text;
                        pboMarkRow.zzdifficulty = textzzdifficulty.Text;
                        pboMarkRow.zzproduceqty = textzzproduceqty.Text;
                        pboMarkRow.zzzwDensity = textzzzwDensity.Text;
                        pboMarkRow.zzbasicspec = "";
                        pboMarkRow.zzproduction = textzzproduction.Text;
                        pboMarkRow.zzspeed = texzzspeed.Text;
                        pboMarkRow.zzzwjgtx = textzzzwjgtx.Text;
                        pboMarkRow.zzyujiproduction = textzzyujiproduction.Text;
                        pboMarkRow.zzmachineqty = textzzmachineqty.Text;
                        state = "覆盖";
                        pbomMaster.pbomMasterInsert(pboMarkRow, pbomMasterRow, ptable, state, textpname.Text);
                        ptable.AcceptChanges();
                        bindingSourcepbomMaster.DataSource = pbomMaster.getpbomMasterAll();
                        MessageBox.Show("保存成功");
                    }
                }
                catch (FormatException ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
            }
        }

        private void 生产通知单制作ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 梳织打印ToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string pname = textpname.Text;
            //  DataSetPrint.pbomTableDataTable pbomTable = new DataSetPrint.pbomTableDataTable();
            //  DataSetPrint.pbomDtailTableDataTable pbomDtailTable = new DataSetPrint.pbomDtailTableDataTable();
            //  DataSetPrint.pbomMarkDataTable pbomMarkTable = new DataSetPrint.pbomMarkDataTable();
            //  DataSetPrint.materialListTableDataTable materialListTable= new DataSetPrint.materialListTableDataTable();
            //  //string matNum = dGridPbomMaster.CurrentRow.Cells["matNum"].Value.ToString();
            //string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            //orderDataSet.pbomDetailDataTable pbomDetailTable = pbomDetail.getpbomDetailbypanmeAll(pname);
            //orderDataSet.pbomMarkDataTable pbomMarkTable2 = pbomMark.getpbomMarkAllBypname(pname);
            //orderDataSet.pbomMasterDataTable pbomMasterTable = pbomMaster.getpbomMasterAllBypname(pname);
            //orderDataSet.materialListDataTable material = materilList.getmaterialListAll  () ;

            #region 旧代码          foreach (orderDataSet.pbomMasterRow pbomMasterRow in pbomMasterTable)

            #endregion          }



            Report r = new Report();
            DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf =0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            //ds.Tables.Add (pbomTable);
            //ds.Tables.Add(pbomDtailTable);
            //ds.Tables.Add(pbomMarkTable);
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomaster.frx");
            r.RegisterData(ds);
          r.Show();
           // r.Design();
        }

        private void 针织打印ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string pname = textpname.Text;
            Report r = new Report();
            DataSet ds = new DataSet();
            // DataTable dt = new DataTable();
            // dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf = 0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomasterzhenzhi.frx");
           r.Load(@"\\192.168.0.27\东华软件\报表\pbomasterzhenzhi.frx");
            r.RegisterData(ds);
           //  r.Design();
            r.Show();
        }

        private void 梳织打印ToolStripMenuItem2_Click(object sender, EventArgs e)
        {
            string pname = textpname.Text;
            //  DataSetPrint.pbomTableDataTable pbomTable = new DataSetPrint.pbomTableDataTable();
            //  DataSetPrint.pbomDtailTableDataTable pbomDtailTable = new DataSetPrint.pbomDtailTableDataTable();
            //  DataSetPrint.pbomMarkDataTable pbomMarkTable = new DataSetPrint.pbomMarkDataTable();
            //  DataSetPrint.materialListTableDataTable materialListTable= new DataSetPrint.materialListTableDataTable();
            //  //string matNum = dGridPbomMaster.CurrentRow.Cells["matNum"].Value.ToString();
            //string pname = dGridPbomMaster.CurrentRow.Cells["pname"].Value.ToString();
            //orderDataSet.pbomDetailDataTable pbomDetailTable = pbomDetail.getpbomDetailbypanmeAll(pname);
            //orderDataSet.pbomMarkDataTable pbomMarkTable2 = pbomMark.getpbomMarkAllBypname(pname);
            //orderDataSet.pbomMasterDataTable pbomMasterTable = pbomMaster.getpbomMasterAllBypname(pname);
            //orderDataSet.materialListDataTable material = materilList.getmaterialListAll  () ;

            #region 旧代码          foreach (orderDataSet.pbomMasterRow pbomMasterRow in pbomMasterTable)

            #endregion          }



            Report r = new Report();
            DataSet ds = new DataSet();
            //DataTable dt = new DataTable();
            //dt.Load(basicSql.getpbomaster(pname));
            ViewDataSet.V_pboMasterDataTable V_PbomTable = pbomMaster.getV_pboMasterAllBypname(pname);
            DataSetPrint.pbomTable1DataTable pbomTable = new DataSetPrint.pbomTable1DataTable();
            foreach (ViewDataSet.V_pboMasterRow V_pbomRow in V_PbomTable)
            {
                DataSetPrint.pbomTable1Row pbomRow = pbomTable.NewpbomTable1Row();
                if (!V_pbomRow.IsmatSpecNull())
                {
                    pbomRow.matSpec = V_pbomRow.matSpec;
                }
                else { pbomRow.matSpec = ""; }
                if (!V_pbomRow.IsmatNameNull())
                {
                    pbomRow.matName = V_pbomRow.matName;
                }
                else { pbomRow.matName = ""; }
                pbomRow.pname = V_pbomRow.pname;
                if (!V_pbomRow.IscustNumNull())
                {
                    pbomRow.custNum = V_pbomRow.custNum;
                }
                else { pbomRow.custNum = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.aweight = V_pbomRow.awgight.ToString();
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.bweight != 0) pbomRow.bweight = V_pbomRow.bweight.ToString();
                else { pbomRow.bweight = ""; }
                if (V_pbomRow.awgight != 0) pbomRow.awgight = V_pbomRow.awgight.ToString();
                else { pbomRow.awgight = ""; }
                pbomRow.createDate = V_pbomRow.createDate.ToString();
                if (!pbomRow.IscreateUserNull())
                {
                    pbomRow.createUser = pbomRow.createUser;
                }
                else { pbomRow.createUser = ""; }
                if (!V_pbomRow.IswbNull())
                {
                    pbomRow.wb = V_pbomRow.wb;
                }
                else { pbomRow.wb = ""; }
                if (V_pbomRow.matNum != "0")
                {
                    pbomRow.matNum = V_pbomRow.matNum;
                }
                else { pbomRow.matNum = ""; }
                if (!V_pbomRow.IsptNull())
                {
                    pbomRow.pt = V_pbomRow.pt;
                }
                else { pbomRow.pt = ""; }
                if (!V_pbomRow.IspzNull())
                {
                    pbomRow.pz = V_pbomRow.pz;
                }
                else { pbomRow.pz = ""; }
                if (!V_pbomRow.IscustNameNull())
                {
                    pbomRow.custName = V_pbomRow.custName;
                }
                else { pbomRow.custName = ""; }
                if (V_pbomRow.alen != 0)
                {
                    pbomRow.alen = V_pbomRow.alen.ToString();
                }
                else { pbomRow.alen = ""; }
                pbomRow.aweight = V_pbomRow.aweight.ToString();
                if (V_pbomRow.ts != 0)
                {
                    pbomRow.ts = V_pbomRow.ts.ToString();
                }
                else { pbomRow.ts = ""; }
                if (V_pbomRow.blen != 0)
                {
                    pbomRow.blen = V_pbomRow.blen.ToString();
                }
                else { pbomRow.blen = ""; }
                if (V_pbomRow.aweight != 0)
                {
                    pbomRow.aweight = V_pbomRow.aweight.ToString();
                }
                else { pbomRow.aweight = ""; }
                if (V_pbomRow.pweight != 0)
                {
                    pbomRow.pweight = V_pbomRow.pweight.ToString();
                }
                else { pbomRow.pweight = ""; }
                if (!pbomRow.IsmarkNull())
                {
                    pbomRow.mark = V_pbomRow.mark;
                }
                else { pbomRow.mark = ""; }
                if (!V_pbomRow.IsrequestNull())
                {
                    pbomRow.request = V_pbomRow.request;
                }
                else { pbomRow.request = ""; }
                if (!V_pbomRow.IsdifficultyNull())
                {
                    pbomRow.difficulty = V_pbomRow.difficulty;
                }
                else { pbomRow.difficulty = ""; }
                if (!V_pbomRow.IsendopenNull())
                {
                    pbomRow.endopen = V_pbomRow.endopen;
                }
                else { pbomRow.endopen = ""; }
                if (!V_pbomRow.IsendshrinkNull())
                {
                    pbomRow.endshrink = V_pbomRow.endshrink;
                }
                else { pbomRow.endshrink = ""; }
                if (!V_pbomRow.IsgqDensityNull())
                {
                    pbomRow.gqDensity = V_pbomRow.gqDensity;
                }
                else { pbomRow.gqDensity = ""; }
                if (!V_pbomRow.IsmethodsNull())
                {
                    pbomRow.methods = V_pbomRow.methods;
                }
                else { pbomRow.methods = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberKf = V_pbomRow.numberKf;
                }
                else { pbomRow.numberKf = ""; }
                if (!V_pbomRow.IsnumberKfNull())
                {
                    pbomRow.numberNf = V_pbomRow.numberNf;
                }
                else { pbomRow.numberNf = ""; }

                if (!V_pbomRow.IsproductionKfNull())
                {
                    pbomRow.productionKf = V_pbomRow.productionKf;
                }
                else { pbomRow.productionKf = 0; }
                if (!V_pbomRow.IsproductionNfNull())
                {
                    pbomRow.productionNf = V_pbomRow.productionNf;
                }
                else { pbomRow.productionNf = 0; }
                if (!V_pbomRow.IsspeedKfNull())
                {
                    pbomRow.speedKf = V_pbomRow.speedKf;
                }
                else { pbomRow.speedKf = ""; }
                if (!V_pbomRow.IsspeedNfNull())
                {
                    pbomRow.speedNf = V_pbomRow.speedNf;
                }
                else { pbomRow.speedNf = ""; }
                if (!V_pbomRow.IsstartopenNull())
                {
                    pbomRow.startopen = V_pbomRow.startopen;
                }
                else { pbomRow.startopen = ""; }
                if (!V_pbomRow.IsstartshrinkNull())
                {
                    pbomRow.startshrink = V_pbomRow.startshrink;
                }
                else { pbomRow.startshrink = ""; }
                if (!V_pbomRow.IsstartwidthNull())
                {
                    pbomRow.startwidth = V_pbomRow.startwidth;
                }
                else { pbomRow.startwidth = ""; }
                if (!V_pbomRow.IsendwidthNull())
                {
                    pbomRow.endwidth = V_pbomRow.endwidth;
                }
                else { pbomRow.endwidth = ""; }
                if (!V_pbomRow.IstwoLengthNull())
                {
                    pbomRow.twoLength = V_pbomRow.twoLength;
                }
                else { pbomRow.twoLength = ""; }
                if (!V_pbomRow.IszwDensityNull())
                {
                    pbomRow.zwDensity = V_pbomRow.zwDensity;
                }
                else { pbomRow.zwDensity = ""; }
                if (!V_pbomRow.IszzbasicspecNull())
                {
                    pbomRow.zzbasicspec = V_pbomRow.zzbasicspec;
                }
                else { pbomRow.zzbasicspec = ""; }
                if (!V_pbomRow.IszzdifficultyNull())
                {
                    pbomRow.zzdifficulty = V_pbomRow.zzdifficulty;
                }
                else { pbomRow.zzdifficulty = ""; }
                if (!V_pbomRow.IszzmachineqtyNull())
                {
                    pbomRow.zzmachineqty = V_pbomRow.zzmachineqty;
                }
                else { pbomRow.zzmachineqty = ""; }
                if (!V_pbomRow.IszzproduceqtyNull())
                {
                    pbomRow.zzproduceqty = V_pbomRow.zzproduceqty;
                }
                else { pbomRow.zzproduceqty = ""; }
                if (!V_pbomRow.IszzproductionNull())
                {
                    pbomRow.zzproduction = V_pbomRow.zzproduction;
                }
                else { pbomRow.zzproduction = ""; }
                if (!pbomRow.IszzrequestNull())
                {
                    pbomRow.zzrequest = V_pbomRow.zzrequest;
                }
                else { pbomRow.zzrequest = ""; }
                if (!V_pbomRow.IszzspeedNull())
                {
                    pbomRow.zzspeed = V_pbomRow.zzspeed;
                }
                else { pbomRow.zzspeed = ""; }
                if (!V_pbomRow.IszzyujiproductionNull())
                {
                    pbomRow.zzyujiproduction = V_pbomRow.zzyujiproduction;
                }
                else { pbomRow.zzyujiproduction = ""; }
                if (!V_pbomRow.IszzzwDensityNull())
                {
                    pbomRow.zzzwDensity = V_pbomRow.zzzwDensity;
                }
                else { pbomRow.zzzwDensity = ""; }
                if (!V_pbomRow.IszzzwjgtxNull())
                {
                    pbomRow.zzzwjgtx = V_pbomRow.zzzwjgtx;
                }
                else { pbomRow.zzzwjgtx = ""; }
                pbomTable.AddpbomTable1Row(pbomRow);

            }
            //ds.Tables.Add (pbomTable);
            //ds.Tables.Add(pbomDtailTable);
            //ds.Tables.Add(pbomMarkTable);
            ds.Tables.Add(pbomTable);
            //r.Load(@"E:\东华软件项目\报表\pbomaster.frx");
            r.Load(@"\\192.168.0.27\东华软件\报表\pbomasterxiao.frx");
            r.RegisterData(ds);
           r.Show();
           // r.Design();
        }

        private void dGridDetail_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

       
        }
    }

